/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: QQAutoConfig
 * Author:   zhouheng
 * Date:     2019/6/15 9:44
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhouh.golden.security.social.qq.config;

import com.zhouh.golden.security.config.GoldenSecurityConfig;
import com.zhouh.golden.security.properties.GoldenSecurityProperties;
import com.zhouh.golden.security.properties.QQProperties;
import com.zhouh.golden.security.properties.SocialProperties;
import com.zhouh.golden.security.social.qq.connect.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.social.autoconfigure.SocialAutoConfigurerAdapter;
import org.springframework.social.config.annotation.ConnectionFactoryConfigurer;
import org.springframework.social.config.annotation.SocialConfigurer;
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
import org.springframework.social.connect.ConnectionFactory;
import org.springframework.web.servlet.View;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author zhouheng
 * @create 2019/6/15
 * @since 1.0.0
 */

@Configuration
@ConditionalOnProperty(prefix = "golden.security.social.qq", name = "app_id")
@Order(2)
public class QQAutoConfig extends SocialAutoConfigurerAdapter {
    @Autowired
    private GoldenSecurityProperties goldenSecurityProperties;

    @Override
    protected ConnectionFactory<?> createConnectionFactory() {
        QQProperties qqConfig = goldenSecurityProperties.getSocial().getQq();
        return new QQConnectionFactory(qqConfig.getProviderId(),qqConfig.getAppId(),qqConfig.getAppSecret());
    }
}